package uk.co.hs.web.controller.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import uk.co.hs.web.interceptor.TabsAccessibilityInterceptor;


/**
 * LoginController.
 */
@Controller("hs_loginController")
@RequestMapping("/" + TabsAccessibilityInterceptor.LOGIN_URL)
public class LoginController
{
  @RequestMapping(method = RequestMethod.GET)
  protected ModelAndView formBackingObject(HttpServletRequest aRequest,
                                           HttpServletResponse aResponse) throws Exception
  {
    SecurityContext securityContext = SecurityContextHolder.getContext();
    securityContext.setAuthentication(null);
    aRequest.getSession().invalidate();
    return new ModelAndView("hs_Login");
  }
}
